import { MessageBox } from 'mint-ui'
import { getSoundUrl } from '@/assets/js/ApiUtil'
export function uploadSoundUntil (el, callback) {
  let file = el.files[0]
  console.log(file)
  const isJPG = file.type === 'audio/mp3'
  const isLt2M = file.size / 1024 / 1024 < 5
  if (!isJPG) {
    MessageBox('上传音频只能是 mp3 格式!')
    return false
  }
  if (!isLt2M) {
    MessageBox('上传音频大小不能超过 5MB!')
    return false
  }
  if (el.files && el.files[0]) {
  // let imgSrc = window.navigator.userAgent.indexOf('Chrome') >= 1 || window.navigator.userAgent.indexOf('Safari') >= 1 ? window.webkitURL.createObjectURL(filHead.files[0]) : window.URL.createObjectURL(filHead.files[0])
  // console.log(imgSrc)
    let formData = new FormData()
    formData.append('files', file)
    getSoundUrl(formData).then(resp => {
      let data = resp.data
      if (data && data instanceof Array) {
        callback(data)
      }
    })
  } else {
    el.select()
    el.blur()
  }
}
